<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    var removeElement = function(nums, val) {
      const result = nums.filter((item)=>{
        return item!=val
      })
      return (nums.splice(0,nums.length,...result)).length
    };
    var nums = [0,0,1,1,1,2,2,3,3,4]
    var len = removeElement(nums,1);
    for (var i = 0; i < len; i++) {
      console.log(nums[i]);
    }
  </script>
</html>
